<?php

namespace App\Http\Controllers\Admin;
use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\hash;
use App\Models\UserModel;

class UserloginController extends Controller
{
    public function login()
    {
        return view('Admin/User/login');

    }
    public function dologin(Request $request)
    {
        //
       $name=$request->input('username');
       $password=$request->input('password');

       $one=User::query()->where('username',$name)->first();

       

    
       if (is_null($one)) {
         return back()->with('err','用户不存在');

       }
       if($password!=$one->password){
        return back()->with('err','密码错误');
       }
    
     
    return view("Admin.Login.index")->with("name",$name);
  }
public function useradd(Request $request)
    {
       
       
    return view("Admin.User.create");
  }
 public function register(Request $request)
    {
        //
        $username=$request->input("username");
        $password=$request->input("password");
        $sex=$request->input("sex");
        $address=$request->input("address");
        $tel=$request->input("tel");
        $typeM=new UserModel();
        $data["username"]=$username;
        $data["password"]=$password;
        $data["sex"]=$sex;
        $data["address"]=$address;
        $data["tel"]=$tel;
        $typeM->add($data);
        return view("Admin/User/login");
    }

}
